package com.yuexi.infrastructure.repository;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yuexi.domain.repository.TableRepository;
import com.yuexi.domain.table.bo.TableBO;
import com.yuexi.infrastructure.converter.Converter;
import com.yuexi.infrastructure.db.entity.Table;
import com.yuexi.infrastructure.db.mapper.TableMapper;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author jie
 * @date 2023/4/5 -15:53
 */
@Repository
public class TableRepositoryImpl extends ServiceImpl<TableMapper, Table>
        implements TableRepository {


    @Override
    public List<TableBO> getAll() {
        LambdaQueryWrapper<Table> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.orderByAsc(Table::getId);
        return Converter.INSTANCE.toTableBOList(super.list(queryWrapper));
    }

    @Override
    public List<TableBO> getByIds(List<String> ids) {
        LambdaQueryWrapper<Table> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.in(Table::getId, ids);
        queryWrapper.orderByAsc(Table::getId);
        return Converter.INSTANCE.toTableBOList(super.list(queryWrapper));
    }
}
